home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / std_unix / archive / text0046.txt < prev    next >
Encoding:
Text File  |  1993-07-06  |  1.2 KB  |  39 lines

  1. Submitted-by: d@exnet.co.uk (Damon)
  2.  
  3. In article <1rro2qINNk3f@ftp.UU.NET> davidm@cimshop.UUCP (David S. Masterson) writes:
  4. >Shouldn't 'printf "%c" 3' output a NULL byte?  I would expect that the '3'
  5. >would be stored in as a 4 byte integer of which the first 3 bytes are '0'.
  6. >The '%c' should take the byte at the address of the argument to printf (not
  7. >what that argument points to) and output it as an ASCII character (in this
  8. >case NULL).  Without testing it, I'm not sure -- is this not what happens?
  9.  
  10. My understanding of printf() as a normal UNIX C library function is
  11. that is prints the byte/character corresponding to the integer passed to
  12. it as in:
  13.  
  14.     {
  15.     int ic;
  16.  
  17.     while((ic = getchar()) != EOF) { printf("%c", ic); }
  18.     }
  19.  
  20.     which should be exactly equivalent to:
  21.  
  22.     {
  23.     int ic;
  24.  
  25.     while((ic = getchar()) != EOF) { putchar(ic); }
  26.     }
  27.  
  28. If %c now behaves like %s then, IMHO, the POSIX group have goofed, big-time.
  29.  
  30. -- 
  31. Damon Hart-Davis   d@hd.org   London UK
  32. Tel/Fax: +44 81 755 0077======Two jobs:
  33. (1) Parallelogram Editor,        [1.42]
  34. (2) Seller of public-access news/mail & cheap Suns (mail info@exnet.co.uk).
  35.  
  36.  
  37. Volume-Number: Volume 31, Number 49
  38.  
  39.